package pers.mine.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import pers.mine.dao.AdminMapper;
import pers.mine.po.Admin;
import pers.mine.service.inter.AdminService;

/**
 * @author Mine
 * @since 2016年10月20日_上午11:01:10
 */
@Service
public class AdminServiceImpl implements AdminService {
	@Autowired
	private AdminMapper am;

	/**
	 * @see pers.mine.service.inter.AdminService#login(java.lang.String,
	 *      java.lang.String)
	 */
	@Override
	public Admin login(String id, String pw) {
		// 验证是否为空
		if (id == null || pw == null || "".equals(id.trim())
				|| "".equals(pw.trim())) {
			return null;
		}
		// 去空格
		id = id.trim();
		pw = pw.trim();
		// 执行查询
		Admin one = am.selectByPrimaryKey(id);
		// 验证密码是否相同,以及账户是否可用
		if (one != null && pw.equals(one.getPw()) && one.getState() == 1) {
			return one;
		}
		return null;
	}

}
